package com.ygp.dtp.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * @description: 拒绝策略枚举类
 * @motto: 代码源于生活，高于生活艺术
 * @author: zhouhengzhe
 * @date: 2022/8/4 16:38
 * @since 1.0
 * todo 要改造
 **/
@Slf4j
@Getter
@AllArgsConstructor
public enum RejectedTypeEnum {
    /**
     * RejectedExecutionHandler type while triggering reject policy.
     */
    ABORT_POLICY("AbortPolicy"),

    CALLER_RUNS_POLICY("CallerRunsPolicy"),

    DISCARD_OLDEST_POLICY("DiscardOldestPolicy"),

    DISCARD_POLICY("DiscardPolicy");

    private final String code;

    private static final String REJECTED_PREFIX = "RejectedCountable";

    public static String formatRejectName(String code) {
        if (code.startsWith(REJECTED_PREFIX)) {
            return code.replace(REJECTED_PREFIX, "");
        }
        return code;
    }
}
